﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace SLAssetSystem
{
    public partial class AssetPaths
    {
        public const string BehaviourPath = "_Output/Configs/Behaviours/";


        public const string ResourcesPath = "";
        public const string PrefabsPath = "Prefabs/";
        public const string WindowPrefabPath = "Prefabs/Windows/";
        public const string EffectPrefabPath = "Prefabs/Effects/";
        public const string CharacterPrefabPath = "Character/Prefabs/";
        public const string BehaviourTreeConfigPath = "Configs/Behaviour/BehaviourTrees/";
        public const string BehaviourConfigPath = "Configs/Behaviour/";

        public const string SoundPath = "Sounds/";


        public const string ConfigsPath = "Configs/";
        public const string CharacterConfigsPath = "Configs/Character/";
        public const string SkillConfigsPath = "Configs/Skill/";
        public const string WindowsConfigPath = "Configs/WindowInfo";
        public const string StageConfigPath = "Configs/Stage/";

        public const string AssetBundlePath = "/../ABs/";
        public const string AssetEditorManifestEditorAssetPath = "Assets/AssetEditorManifest.asset";
        public const string AssetManifestEditorAssetPath = "Assets/AssetManifest.asset";

        public const string ABExtension = ".ab";
        public static string AssetManifestAssetDebugPath
        {
            get
            {
                if (string.IsNullOrEmpty(assetManifestAssetDebugPath))
                {
                    assetManifestAssetDebugPath = string.Format("{0}/version.ab", StreamingAssetsPath);
                }
                return assetManifestAssetDebugPath;
            }
        }
        private static string assetManifestAssetDebugPath = null;

        public static string AssetManifestAssetPath
        {
            get
            {
                if (string.IsNullOrEmpty(assetManifestAssetPath))
                {
                    assetManifestAssetPath = string.Format("{0}/version.ab", PersistentDataPath);
                }
                return assetManifestAssetPath;
            }
        }
        private static string assetManifestAssetPath = null;

        public static string PersistentDataPath
        {
            get
            {
                if (string.IsNullOrEmpty(persistentDataPath))
                {
                    persistentDataPath = Application.persistentDataPath;
                }
                return persistentDataPath;
            }

        }
        private static string persistentDataPath = null;

        public static string ABDownLoadPath;
        public static string ABCachePath;

        public static string StreamingAssetsPath
        {
            get
            {
                if (string.IsNullOrEmpty(streamingAssetsPath))
                {
                    streamingAssetsPath = Application.streamingAssetsPath;
                }
                return streamingAssetsPath;
            }

        }
        private static string streamingAssetsPath = null;


        public static string GetRuntimePlatformName()
        {
            switch (Application.platform)
            {
                case RuntimePlatform.Android:
                    return "Android";
                case RuntimePlatform.OSXPlayer:
                    return "OSX";
                case RuntimePlatform.WindowsPlayer:
                    return "Windows";
                case RuntimePlatform.IPhonePlayer:
                    return "IOS";
                case RuntimePlatform.WebGLPlayer:
                    return "WebGL";
                default:
                    return "Unsupported";
            }
        }

        public static string GetBuildPath(string fileName)
        {
            if (fileName.Contains("Resources/"))
            {
                fileName = fileName.Substring(fileName.LastIndexOf("Resources/") + 10);
            }
            return fileName;
        }

        public static string GetBundlePath()
        {
            return Application.streamingAssetsPath;
        }

        public static string GetResourcesPath(string path)
        {
            if (path.Contains("Resources/"))
            {
                path = path.Substring(path.LastIndexOf("Resources/") + 10);
            }
            return path;
        }

        public static string GetFileWithoutExtension(string name)
        {
            if (name.Contains('.'))
            {
                int index = name.IndexOf('.');
                name = name.Substring(0, index);
            }
            return name;
        }

        public static string GetFileNameWithExtension(string name)
        {
            name = name.Substring(name.LastIndexOf('/') + 1);
            return name;
        }

        public static string GetFileName(string name)
        {
            name = name.Substring(name.LastIndexOf('/') + 1);
            name = name.Substring(0, name.LastIndexOf("."));
            return name;
        }



    }
}
